"""
用户收获地址界面
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from page.base_page import BasePage
class UserAddress(BasePage):
    # def __init__(self,driver):
    #     self.driver=driver
    #定位器
    delate_locator=(By.XPATH,"/html/body/div[8]/div[2]/div/div/div/form[1]/table/tbody/tr[6]/td[2]/input[2]")
    countries_locator=(By.ID,"selCountries_2")
    provinces_locator=(By.ID,"selProvinces_2")
    cities_locator=(By.ID,"selCities_2")
    districts_locator=(By.ID,"selDistricts_2")
    consignee_locator=(By.ID,"consignee_2")
    address_locator=(By.ID,"address_2")
    tel_locator=(By.ID,"tel_2")
    add_btn_locator=(By.CSS_SELECTOR,"body > div.block.clearfix > div.AreaR > div > div > div > form:nth-child(8) > table > tbody > tr:nth-child(6) > td:nth-child(2) > input.bnt_blue_2")
    def deleteaddress(self):
        self.driver.find_element(*self.delate_locator).click()
    def switchdeleteaddress(self):
        self.driver.switch_to.alert.accept()
    def addresstext(self):
        address = self.driver.find_element(By.CSS_SELECTOR,"#address_0").get_attribute("value")
        return address
    def selectcountries(self):
        countries_element=self.driver.find_element(*self.countries_locator)
        countries_select=Select(countries_element)
        countries_select.select_by_visible_text("中国")
    def selectprovinces(self):
        provinces_element=self.driver.find_element(*self.provinces_locator)
        provinces_select=Select(provinces_element)
        provinces_select.select_by_visible_text("四川")
    def selectcities(self):
        cities_element=self.driver.find_element(*self.cities_locator)
        cities_select=Select(cities_element)
        cities_select.select_by_visible_text("成都")
    def selectdistricts(self):
        districts_element=self.driver.find_element(*self.districts_locator)
        districts_select=Select(districts_element)
        districts_select.select_by_visible_text("锦江区")
    def consignee(self):
        self.driver.find_element(*self.consignee_locator).send_keys("admin")
    def address(self):
        self.driver.find_element(*self.address_locator).send_keys("海德学校")
    def telphone(self):
        self.driver.find_element(*self.tel_locator).send_keys("18349332288")
    def addbtn(self):
        self.driver.find_element(*self.add_btn_locator).click()
    def nowaddresstxt(self):
        address = self.driver.find_element(By.CSS_SELECTOR,"#address_2").get_attribute("value")
        return address
